home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 128 #10 / q10.d81 / t.shell asm < prev    next >
Encoding:
Text File  |  1990-01-01  |  19.1 KB  |  496 lines

  1.  
  2.            L O A D S T A R   1 2 8   E D I T O R / A S S E M B L E R
  3.  
  4.                              by Robert Rockefeller
  5.  
  6.  
  7.     The Loadstar 128 Editor/Assembler package is a necessary tool for
  8. writing machine language.  You must know how to do it already -- this will
  9. not teach you -- but it will make it a LOT easier.  This article will only
  10. document the assembler/editor features.
  11.  
  12.     The editor, named "COM.EDT", and the assembler, named "COM.ASM", are
  13. designed to be used in conjunction with the shell program published on this
  14. issue of LOADSTAR.  Execute the shell program by typing RUN"128 SHELL" then
  15. type RETURN.
  16.  
  17. EDITOR
  18. ------
  19.  
  20.     The editor is a full-screen programmer's text editor which creates PET
  21. ASCII program files.  A programmer's text editor differs from a
  22. wordprocessor in that it typically cannot format and print out text files. 
  23. It's for editing code only.
  24.  
  25.     After the shell is loaded, you execute the editor by typing EDT then
  26. RETURN.  A file can be specified for editing by following EDT with a
  27. filename.  For example, if EDT "ASM.COPY is executed the editor will be
  28. loaded, then the text file "ASM.COPY" will automatically be loaded into the
  29. editor from disk device 8.  An alternate device number for the text file can
  30. be specified by prefixing it to the filename.  For example, EDT 9,"ASM.COPY
  31. would try to load "ASM.COPY" from device 9.
  32.  
  33.     EDT can work on files completely in RAM by specifying EDT RAM instead of
  34. a filename.  Typically you would use EDT to create a text file to be
  35. assembled.  You would then exit the editor and assemble the file with ASM. 
  36. You could then type EDT RAM to re-edit the text already in RAM without the
  37. necessity of loading the text in from disk.  Of course you must be sure that
  38. the text has not been corrupted in any way in the meantime.  Therefore avoid
  39. loading in BASIC programs between uses of EDT if you wish to use the RAM
  40. option.  It is also a good idea to save a copy of your source code to disk
  41. after making changes just in case.
  42.  
  43.     EDT files are suitable for use by the "COM.SUBMIT" program published
  44. with the shell program. SUBMIT allows you to execute text in "SUB." files as
  45. if the text were entered at the keyboard.  You can use "SUB." files to
  46. redefine the function keys, RUN BASIC programs, control the assembler, etc. 
  47. If you're familiar with MS DOS, think of "SUB." files as "batch" files.
  48.  
  49.     Some keyboard conventions are used when explaining EDT functions.  F1 @
  50. means type the F1 key and release it, then type the @ key and release it.  A
  51. slash (/) is used to show that two keys are to be pressed simultaneously. 
  52. SHIFT/RETURN means press a SHIFT key and the RETURN key at the same time. 
  53. EDT functions are explained below.
  54.  
  55. ESC 1 - Set the text color.
  56.  
  57. ESC 2 - Set the screen color.
  58.  
  59. ESC @ - Clear text from the cursor position to the end of the file.
  60.  
  61. ESC a - Turn insert mode on.
  62.  
  63. ESC c - Turn insert mode off.
  64.  
  65. ESC d - Erase the whole line.
  66.  
  67. ESC g - Enable bell ringing for errors.
  68.  
  69. ESC h - Disable bell ringing for errors.
  70.  
  71. ESC j - Move the cursor to the start of the line.
  72.  
  73. ESC k - Move the cursor to the end of the line.
  74.  
  75. ESC n - Set the screen to normal (non-reversed) mode.
  76.  
  77. ESC p - Erase to the start of the line.
  78.  
  79. ESC q - Erase to the end of the line.
  80.  
  81. ESC r - Set the screen to reversed mode.
  82.  
  83. ESC v - Scroll the screen up.
  84.  
  85. ESC w - Scroll the screen down.
  86.  
  87. F1 @ - Read the disk error channel, or issue a disk command.  Type F1 @
  88. RETURN to read the error channel of the default disk drive.  To read some
  89. other device enter a device number followed by a comma.  For example type F1
  90. @ 9, RETURN to read the error channel of device 9.  To issue a disk command
  91. just type F1 @ then type the command at the prompt, and type RETURN.  To
  92. send a command to a device other than the default device number, just prefix
  93. the device number to the command.  For example, typing F1 @ 9,i0 RETURN
  94. would initialize disk device 9.
  95.  
  96. F1 d - Set the default disk device number.  The default disk device number
  97. is always displayed as the number at the extreme left of the status line.
  98.  
  99. F1 m - Display the number of free bytes available for text storage.
  100.  
  101. F1 s - Search for a string.  Just enter the string at the prompt and type
  102. RETURN.
  103.  
  104. F1 e - Save the editor to disk.  First select the screen colors you like
  105. with ESC 1 and ESC 2, then type F1 e, then enter the disk device number to
  106. which you wish to save the editor, then type RETURN.
  107.  
  108. F1 r - Replace a string.  First enter the string to be replaced, then enter
  109. the string to replace with.  Finally, if you wish to be prompted before each
  110. replacement type y at the PROMPT BEFORE REPLACING? prompt, else type n.
  111.  
  112. F1 v - Display a text file on disk.  Enter the name of the file you wish to
  113. view then type RETURN.  The file will be printed to the screen.  To view
  114. from a disk other than the default disk you prefix a device number to the
  115. filename. For example, if you enter a filename of 9,ERR.COPY the file
  116. "ERR.COPY" would be displayed from device 9.
  117.  
  118. F1 b - Exit the editor.  Return to the BASIC environment.
  119.  
  120. RETURN - Start a new line.  Inserts a carriage-return character into the
  121. text area.  Any text to the right of the cursor will be moved to the next
  122. line when RETURN is typed.
  123.  
  124. CONTROL/p - Insert the text buffer at the cursor position.  Text can be
  125. copied into the text buffer by marking a block (see SHIFT/F7) then typing c.
  126.  
  127. SHIFT/HOME - Clear all text.  You must type y at the prompt before text is
  128. actually cleared.
  129.  
  130. HELP - Display help screens.
  131.  
  132. DEL - Delete the character to the left of the cursor.
  133.  
  134. CRSR keys - Work as you would expect them to.
  135.  
  136. down-arrow - Scroll the screen down one row.
  137.  
  138. up-arrow - Scroll the screen up one row.
  139.  
  140. HOME up-arrow - Move the cursor to the top, left corner of the screen.
  141.  
  142. HOME down-arrow - Move the cursor to the bottom, left corner of the screen.
  143.  
  144. HOME left-arrow - Move the cursor to the start of the text area.
  145.  
  146. HOME right-arrow - Move the cursor to the end of the text.
  147.  
  148. HOME cursor-down - Goto a specified line number.  Type the number of the
  149. line you wish to go to, then type RETURN.
  150.  
  151. F3 - Display a disk directory.  Enter the device number of the disk you wish
  152. to view.
  153.  
  154. F5 - Save the text to a disk drive.  Enter the filename at the prompt.  To
  155. save to a disk other than the default disk you prefix a device number to the
  156. filename.  For example, if you enter a filename of 9,SUB.KEYS the text would
  157. be saved to disk device 9 with the name "SUB.KEYS".
  158.  
  159. F7 - Delete the character under the cursor.
  160.  
  161. F2 - Load a file.  Enter the name of the file you wish to load.  To load
  162. from a disk other than the default you prefix a device number to the
  163. filename.  For example, if you enter a filename of 9,SUB.KEYS the file
  164. "SUB.KEYS" would be loaded from device 9.
  165.  
  166. F4 - Search ahead for the next occurrence of the last string searched for.
  167.  
  168. F8 - Begin marking a text block.  Move the cursor to the other end of the
  169. block.  The block is displayed in reverse field as the cursor is moved. 
  170. After the block is marked there are three operations that can be performed
  171. on the block.
  172.  
  173.     Type s to save the block to disk.
  174.  
  175.     Type c to copy the block to the text buffer.  The block can be inserted
  176. into the text area with CONTROL/p.
  177.  
  178.     Type DEL to delete the block.  The block is copied to the text buffer
  179. before deletion.  The block can be recovered with CONTROL/p.
  180.  
  181. ASSEMBLER
  182. ---------
  183.  
  184.     The assembler is executed by typing ASM and the name of a file to
  185. assemble, then RETURN.  For example, if ASM "COPY is executed the assembler
  186. will be loaded, then the source file "ASM.COPY" will be assembled.  All
  187. assembler source files must have ASM.  as the first four characters of their
  188. filenames.  However, leave off the ASM.  prefix when specifying filenames
  189. for the assembler.  The assembler automatically adds ASM. to each filename.
  190.  
  191.     ASM can assemble files completely in RAM by specifying ASM RAM instead
  192. of a filename.  Typically you would use EDT to create a text file to be
  193. assembled.  You would then exit the editor, and type ASM RAM to assemble the
  194. text already in memory without the necessity of loading the text in from
  195. disk.  If you load in a BASIC program in the meantime, however, the
  196. assembler may have been corrupted.
  197.  
  198.     In addition to a source filename a number of commands can be passed to
  199. the assembler.  They are:
  200.  
  201. a - Specify primary source device number.  This device is checked first for
  202. source files.  The default device number is 8.  For example, if ASM "COPY"
  203. A9 is specified device 9 will be searched first for source files.
  204.  
  205. b - Specify secondary source device number.  The default device number is 9.
  206.  This device is checked second for source files, only if a source file is
  207. not found on the primary device.  For example, if ASM "COPY" B8 is specified
  208. device 8 will be searched second for source files.
  209.  
  210. e - Specify which device to send the error file to.  A device number of 0
  211. disables error output.  The default device is 3, the screen.  However an
  212. error file can be sent to a printer or disk also.  Error files output to
  213. disk will have the letters ERR.  prefixed to the filename.  For example, if
  214. ASM "COPY" E9 is specified an error file with filename "ERR.COPY" would be
  215. sent to device 9.
  216.  
  217. p - Specify which device to send the printout file to.  A device number of 0
  218. disables list output.  The default device number is 0.  A listing file can
  219. be sent to the screen, a printer, or to a disk.  Listing files output to
  220. disk will have the letters PRN.  prefixed to the filename.  For example, if
  221. ASM "COPY" P8 is specified a list file with filename "PRN.COPY" would be
  222. sent to device 8.
  223.  
  224. s - Specify which device to save the symbol table on.  After assembly the
  225. assembler can save the symbol table to disk.  A future symbolic debugger
  226. will be able to load this symbol table to provide symbolic disassemblies. 
  227. Symbol tables saved to disk will have the letters SYM.  prefixed to the
  228. filename.  For example, if ASM "COPY" S8 is specified the symbol table will
  229. be saved with the filename "SYM.COPY" on device 8.
  230.  
  231. o - Specify which device to write the assembled program object code to.  The
  232. default device is 8.  Assembled programs written to disk will have the
  233. letters OBJ.  prefixed to the filename.  For example, if ASM "COPY" O9 is
  234. specified the object code will be saved with the filename "OBJ.COPY" on
  235. device 9.
  236.  
  237. l - Set maximum line length for the printout file.  The default length is 80
  238. columns.  You might want to change this if outputting a listing to a
  239. printer.  Line length can be set from 40 to 131 columns wide.
  240.  
  241.     There are several switches which can be used to select between several
  242. assembler modes.  They are listed below:
  243.  
  244. -s  If a listing file is being produced by the assembler normally the source
  245. code listing is produced followed by the printout of the symbol table.  The
  246. -s switch disables output of the symbol table printout.
  247.  
  248. -l  If a listing file is being produced by the assembler normally the source
  249. code listing is produced followed by the printout of the symbol table.  The
  250. -l switch disables output of the source code listing.
  251.  
  252. +c  Normally the assembler ignores the case of symbols, that is, no
  253. distinction is made between capital and lower case letters.  For example,
  254. the assembler regards the symbols Label, label, and LABEL as identical.  The
  255. +c switch enables case distinction so that capital and lower case letters
  256. are regarded as different.
  257.  
  258. +f  The +f switch if enabled causes a line feed character to be printed
  259. after a carriage-return during printout.  Some printers require this.
  260.  
  261. Example: ASM "PAINT" P4 A9 B8 O9 -L +F
  262.  
  263. Assemble the file "ASM.PAINT" with primary source device as 9, secondary 8. 
  264. Send a printout only of the symbol table to printer device 4, with line
  265. feeds enabled.  Write the assembled object code to device 9 as "OBJ.PAINT". 
  266. Note the ASM command can be defined in a function key, or executed with a
  267. SUBMIT file.
  268.  
  269.     Each assembly source line consists of four fields, the label field, the
  270. opcode field, the operand field, and the comment field.  Each field must be
  271. separated by one or more TAB characters and/or spaces.  On any given line
  272. any or all of these fields may be missing.  Labels must be terminated with a
  273. colon.  Comments must be preceded with a semi-colon.  This valid line 
  274. contains all four fields.
  275.  
  276. Label1: lda (txtptr),y   ;get a byte.
  277.  
  278.     The assembler accepts literals in three radices, decimal, hexadecimal,
  279. and binary.  Character literals must be preceded by the single quote
  280. character.  Note that character literals can be added, multiplied, etc.,
  281. like any other number.  Examples are:
  282.  
  283. Decimal   234
  284. Hex       $ff11
  285. Binary    %10101111
  286. Character 'a
  287.  
  288.     Assembler symbols may consist of the capital letters A to Z, lower case
  289. letters a to z, the digits 0 to 9, or the underscore character (CMDR/@). 
  290. Symbols can be up to 31 characters long, but only the first 15 characters
  291. are signifigant.  Labels must be terminated by a colon character :.  Equates
  292. may be created with the = operator and must not be terminated by a colon. 
  293. Here is an example of an equate.
  294.  
  295. Chrout   = $ffd2
  296.  
  297. Here is an example of a valid label.
  298.  
  299. longlabel:
  300.  
  301.     The assembler has a fairly good expression evaluator with 11 operators,
  302. and nested parenthesization.  An expression is any legal combination of
  303. symbols, literals, and operators which the assembler will resolve to a
  304. single number.  Operators have different precedence values.  Operators with
  305. higher precedence are evaluated first.  Operators of the same precedence are
  306. evaluated left to right.  For example consider the expression 2+3*3.  Is the
  307. answer 15 or 11?  Since multiplication has a higher precedence the
  308. multiplication is performed first and the answer is 11.  If it is necessary
  309. for the addition to be performed first group it in parentheses like this
  310. (2+3)*3.  The operators and their precedence values are listed below.
  311.  
  312. Operator  Explanation      Precedence
  313.  
  314. unary - two's complement     7
  315. <       low byte             7
  316. >       high byte            7
  317. *       multiply             6
  318. /       divide               6
  319. //      modulus              6
  320. +       addition             5
  321. -       subtraction          5
  322. &       logical and          4
  323. !       logical exclusive-or 3
  324. {$7d}       logical or           2
  325.  
  326.     You must be careful when using parentheses to group sub-expressions
  327. since the assembler uses enclosing parentheses to indicate indirect
  328. addressing mode.  For example:
  329.  
  330.    lda (30+2)*(5+6),y
  331.  
  332. Although absolute addressing mode is desired here the assembler will try to
  333. assemble this instruction with indirect indexed mode due to the enclosing
  334. parentheses.  To avoid this problem prefix a plus sign when absolute
  335. addressing mode is needed, like this:
  336.  
  337.    lda +(30+2)*(5+6),y
  338.  
  339. The plus sign doesn't affect the value of the expression, and prevents the
  340. assembler from using the incorrect mode.
  341.  
  342.     The asterisk * is used as special symbol by the assembler and always
  343. equals the current value of the Program Counter.  As such the asterisk can
  344. be used in expressions like any other number.  For example, the following
  345. two instructions are equivalent.  Both jump to themselves.
  346.  
  347. Label1: jmp Label1
  348.  
  349.        jmp *
  350.  
  351.     The assembler has 15 directives which are explained below.
  352.  
  353.  .list
  354.  .nolist
  355.  
  356. Enable or disable listing output to the printout device.  Note that the
  357. symbol table printout is not affected by these two commands.
  358.  
  359.  .nosym
  360.  
  361. Disable output of the symbol table printout to the printout device.
  362.  
  363.  .nohdr
  364.  
  365. Disable the printing of headers at the top of each page during printout.
  366.  
  367.  .gen
  368.  .nogen
  369.  
  370. Sometimes the .byte, .word, or .dbyte commands generate more than three
  371. bytes per line.  .gen enables the listing of all generated bytes.  .nogen
  372. causes only the first 3 generated bytes to be listed.
  373.  
  374.  .page
  375.  
  376. This directive causes blank lines to be printed until the current printout
  377. page is finished off, then a new page is started.
  378.  
  379.  .space
  380.  
  381. Specify that a number of blank lines be printed to the printout device.  For
  382. example .space 5 would cause five blank lines to be output.
  383.  
  384.  .title
  385.  
  386. Define the program title which will be printed at the top of each printout
  387. page if headers are enabled.  See .nohdr above.  Example: .title Super
  388. Database
  389.  
  390.  .end
  391.  
  392. The .end directive terminates assembly.  Each assembler program must contain
  393. the .end directive exactly once at the end of the program.
  394.  
  395.  .include
  396.  
  397. This directive is used to load further source files from disk.  Practically
  398. speaking, the assembler will substitute the source file text for the
  399. .include directive.  The assembler always loads source files into memory in
  400. their entirety, so combined source file size must be such that a source file
  401. containing an .include, and the included file must both be able to fit in
  402. memory at once.  When specifying the name of the file to be loaded do not
  403. use the ASM.  prefix.  The assembler adds this prefix automatically.  For
  404. example, .include buffers would load the file "ASM.BUFFERS".
  405.  
  406.  .byte
  407.  
  408. This directive accepts a number of expressions which must evaluate to 8-bit
  409. values.  Each value is then output to the object device.  Strings may be
  410. included and must be enclosed in double quotes.  Use commas as separators.  
  411. Example:
  412.  
  413.  .byte 13,13,"this is a string",0
  414.  
  415.  .word
  416.  
  417. This directive accepts a number of expressions which must evaluate to 16-bit
  418. values.  Each value is then output to the object device with the low byte
  419. being output first.  Use commas as separators.  Example:
  420.  
  421.  .word $ff22,ArgTable,3
  422.  
  423.  .dbyte
  424.  
  425. This directive accepts a number of expressions which must evaluate to 16-bit
  426. values.  Each value is then output to the object device with the high byte
  427. being output first.  Use commas as separators.  Example:
  428.  
  429.  .dbyte $ff22,ArgTable,3
  430.  
  431.  .rmb
  432.  *=*+
  433.  
  434. These directives are functionally equivalent and are used to allocate memory
  435. for variables, buffers, etc.  The examples below would allocate two bytes.
  436.  
  437.  .rmb 2
  438.  *=*+2
  439.  
  440.  *=
  441.  
  442. Assign a value to the assembler Program Counter.  This is normally done
  443. prior to defining zero page variables, and prior to generating code.  For
  444. example:
  445.  
  446.  *= 2
  447. zpvar1: .rmb 2  ;create zero page variables.
  448. zpvar2: .rmb 2
  449.  *= $1c03       ;generate code.
  450.  lda #5         ;the program starts here.
  451.  
  452.     The assembler has comprehensive error checking with two types of errors,
  453. fatal and non-fatal.  Fatal errors immediately suspend assembly.  If a
  454. non-fatal error occurs the assembler will continue assembly but will report
  455. the error through the error file and the printout file.  The error numbers
  456. and their meanings are listed below.
  457.  
  458. Fatal Error  Meaning
  459.  
  460.  0  RUN/STOP was pressed.
  461.  1  disk error.
  462.  3  error was returned by disk error channel.
  463.  4  couldn't find a file.
  464.  5  device not present.
  465.  6  missing filename.
  466.  7  source file was corrupted.
  467.  8  out of memory.
  468.  9  illegal device number.
  469.  10 line too long.
  470.  11 symbol table overflow.
  471.  
  472. Error  Meaning
  473.  
  474.  0  multiply defined symbol.
  475.  1  illegal character in symbol.
  476.  2  undefined symbol was referenced.
  477.  3  branch out of range.
  478.  4  mismatched parenthesis.
  479.  5  invalid expression.
  480.  6  expression was too complex.
  481.  7  division by zero error.
  482.  8  missing operand.
  483.  9  syntax error.
  484.  10 16-bit value where 8-bit value was required.
  485.  11 incomplete addressing mode specification.
  486.  14 symbol was too long.
  487.  15 phase error.  Program Counter was out of phase on passes 1 and 2.
  488.  16 wasted byte.  Assembler used absolute mode where zero page
  489.     addressing mode would suffice.  Caused by a forward reference to
  490.     a zero page variable.
  491.  17 invalid addressing mode.
  492.  19 overflowed 64K RAM bank.
  493.  
  494. RR
  495.                              **** End of Text ****
  496.